<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- index.qdoc -->
  <title>qesp : QextSerialPort Manual</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="postheader" valign="center"><a href="index.html">Home</a> &middot; <a href="classes.html">All Classes</a> &middot;</td></tr></table><li>QextSerialPort Manual</li>
<h1 class="title">QextSerialPort Manual</h1>
<span class="subtitle"></span>
<!-- $$$index.html-description -->
<div class="descr"> <a name="details"></a>
<a name="overview"></a>
<h2>Overview</h2>
<p><a href="qextserialport.html">QextSerialPort</a> provides an interface to old fashioned serial ports for Qt-based applications. It currently supports Mac OS X, Windows, Linux, FreeBSD.</p>
<p>From <a href="qextserialport.html">QextSerialPort</a> 1.2-beta on, license of the project has been changed to MIT.</p>
<ul>
<li>Revision 0.9&#x2e;x is Qt 2 &amp; 3 compatible.</li>
<li>Revision 1.x&#x2e;x is Qt 4 compatible.</li>
<li>From revision 1.2beta1 on, Qt 5 support is added.</li>
</ul>
<a name="classes"></a>
<h2>Classes</h2>
<ul>
<li><a href="qextserialport.html">QextSerialPort</a> encapsulates a serial port on both POSIX and Windows systems.</li>
<li><a href="qextserialenumerator.html">QextSerialEnumerator</a> enumerates ports currently available in the system.</li>
</ul>
<a name="getting-started"></a>
<h2>Getting Started</h2>
<a name="usage-1-source-code-only"></a>
<h3>Usage(1): Source Code Only</h3>
<p>The package contains a qextserialport.pri file that allows you to integrate the component into programs that use qmake for the build step.</p>
<p>Download the source code. Put the source code in any directory you like. For example, 3rdparty:</p>
<pre class="cpp">    <span class="operator">|</span><span class="operator">-</span><span class="operator">-</span> project<span class="operator">.</span>pro
    <span class="operator">|</span><span class="operator">-</span><span class="operator">-</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
    <span class="operator">|</span><span class="operator">-</span><span class="operator">-</span> <span class="number">3rdparty</span>\
    <span class="operator">|</span>     <span class="operator">|</span><span class="operator">-</span><span class="operator">-</span> qextserialport\
    <span class="operator">|</span>     <span class="operator">|</span></pre>
<p>Add following line to your qmake project file:</p>
<pre class="cpp">    <span class="keyword">include</span>(pathToPri<span class="operator">/</span>qextserialport<span class="operator">.</span>pri)</pre>
<p>Then, using <a href="qextserialport.html">QextSerialPort</a> in your code</p>
<pre class="cpp">    <span class="preprocessor">#include &quot;qextserialport.h&quot;</span>
    <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
    MyClass<span class="operator">::</span>MyClass()
    {
        port <span class="operator">=</span> <span class="keyword">new</span> QextSerialPort(<span class="string">&quot;COM1&quot;</span>);
        connect(port<span class="operator">,</span> SIGNAL(readyRead())<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(onDataAvailable()));
        port<span class="operator">-</span><span class="operator">&gt;</span>open();
    }

    <span class="type">void</span> MyClass<span class="operator">::</span>onDataAvailable()
    {
        <span class="type"><a href="http://qt-project.org/doc/qt-4.8/qbytearray.html">QByteArray</a></span> data <span class="operator">=</span> port<span class="operator">-</span><span class="operator">&gt;</span>readAll();
        processNewData(usbdata);
    }</pre>
<a name="usage-2-shared-library"></a>
<h3>Usage(2): shared library</h3>
<p>Although <a href="qextserialport.html">QextSerialPort</a> can be directly compiled into your application, You may prefer to use QextSerailPort as an library, which is very easy too.</p>
<p>1. Download the source code, and put it in any location you like.</p>
<p>2. Goto the top level directory ,run following command to generate library.</p>
<pre class="cpp">        qmake
        sudo make install (<span class="keyword">or</span> nmake install)</pre>
<p>3. Add following line to your project's file</p>
<pre class="cpp">        CONFIG <span class="operator">+</span><span class="operator">=</span> extserialport</pre>
<p>4. Using <a href="qextserialport.html">QextSerialPort</a> in your code. Enjoy it!</p>
<pre class="cpp">        <span class="preprocessor">#include &quot;qextserialport.h&quot;</span>
        <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
        QextSerialPort <span class="operator">*</span> port <span class="operator">=</span> <span class="keyword">new</span> QextSerialPort();
        <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span><span class="operator">.</span></pre>
<a name="usage-3-static-library"></a>
<h3>Usage(3): Static library</h3>
<p>Someone prefer to use QextSerailPort as static library.</p>
<p>Open the project file: qextserialport.pro, add uncomment follow line</p>
<pre class="cpp">         <span class="preprocessor"># CONFIG += qesp_static</span></pre>
<p>Then follow the same steps as shared library</p>
<pre class="cpp">         qmake
         sudo make install</pre>
<p>The static library, the header files, and the feature file will be installed to your system.</p>
<p>Add following line to your qmake's project file:</p>
<pre class="cpp">        CONFIG <span class="operator">+</span><span class="operator">=</span> extserialport</pre>
<a name="platform-special"></a>
<h2>Platform Special</h2>
<a name="for-macx-build-as-framework"></a>
<h3>For MacX: Build as framework</h3>
<p>Open the project file: *qextserialport.pro*, and uncomment follow line</p>
<pre class="cpp">         <span class="preprocessor"># CONFIG += qesp_mac_framework</span></pre>
<p>Then follow the same steps as shared library, Goto the top level directory , and run</p>
<pre class="cpp">         qmake
         sudo make install</pre>
<p>The framework which includes libraries and the header files, and the feature file will be installed to your system.</p>
<p>Add following line to your qmake's project file:</p>
<pre class="cpp">         CONFIG <span class="operator">+</span><span class="operator">=</span> extserialport</pre>
<a name="for-linux-enable-udev"></a>
<h3>For Linux: Enable udev</h3>
<p>Open the project file: *qextserialport.pro*, uncomment follow line</p>
<pre class="cpp">         <span class="preprocessor">#linux*:CONFIG += qesp_linux_udev</span></pre>
<p>Note, If you are using the usage(1), Add following line before include the qextserialport.pri file.</p>
<pre class="cpp">         CONFIG <span class="operator">+</span><span class="operator">=</span> qesp_linux_udev</pre>
<a name="build-documents"></a>
<h3>Build documents</h3>
<pre class="cpp">      make docs</pre>
<a name="examples"></a>
<h2>Examples</h2>
<ul>
<li><a href="examples-enumerator.html">examples/enumerator</a></li>
<li><a href="examples-qespta.html">examples/qespta</a></li>
<li><a href="examples-uartassistant.html">examples/uartassistant</a></li>
</ul>
<a name="resources"></a>
<h2>Resources</h2>
<a name="nokia-trolltech"></a>
<h3>Nokia(Trolltech)</h3>
<ul>
<li><a href="http://doc.trolltech.com/qq/qq12-iodevice.html">Writing a Custom I/O Device</a></li>
<li><a href="http://doc.trolltech.com/3.3/qiodevice.html">Qt 3.3: QIODevice Class Reference</a></li>
<li><a href="http://doc.trolltech.com/4.7/qiodevice.html">Qt 4.7: QIODevice Class Reference</a></li>
</ul>
<a name="msdn"></a>
<h3>MSDN</h3>
<ul>
<li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_resources.asp">Communications Resources</a></li>
<li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/about_communications_resources.asp">About Communications Resources</a></li>
<li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/using_communications_resources.asp">Using Communications Resources</a></li>
<li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_functions.asp">Communications Functions</a></li>
<li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_structures.asp">Communications Structures</a></li>
</ul>
<a name="tldp"></a>
<h3>TLDP</h3>
<ul>
<li><a href="http://www.tldp.org/HOWTO/Serial-HOWTO.html">Serial HOWTO</a></li>
<li><a href="http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/">Serial Programming HOWTO</a></li>
</ul>
<a name="other"></a>
<h3>Other</h3>
<ul>
<li><a href="http://www.easysw.com/~mike/serial/serial.html">Serial Programming Guide for POSIX Operating Systems</a></li>
</ul>
</div>
<!-- @@@index.html -->
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2000-2012</td>
<td width="20%" align="center"><a href="http://code.google.com/p/qextserialport">QextSerialPort Project</a></td>
<td width="40%" align="right"><div align="right">QextSerialPort Manual</div></td>
</tr></table></div></address></body>
</html>
